package com.hzqy.service.epg;

import com.hzqy.persistence.dao.epg.AcSvcVoteTotalDao;
import com.hzqy.web.vo.CmVoteTotalVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AcSvcVoteToTalService {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private AcSvcVoteTotalDao acDao;
	public  Map<String,Object> acSvcVoteTotalList(CmVoteTotalVo acv, int page, int rows){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("f_csvt_obligate1",acv.getF_csvt_obligate1());
        map.put("f_csvt_activityid",acv.getF_csvt_activityid());
        Integer rowCount = acDao.acSvcVoteTotalCount(map);
        map.put("total", rowCount);
        if(rowCount>0 && page>0 && rows>0){
            map.put("firstResult", (page-1)*rows);
            map.put("maxResults", rows);
            List<CmVoteTotalVo> list=acDao.acSvcVoteTotalList(map);
            map.put("rows", list);
        }else{
            map.put("rows", new ArrayList<CmVoteTotalVo>());
        }
        return map;
	}
	public  Integer acSvcVoteTotalCount(CmVoteTotalVo acv){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("f_csvt_obligate1",acv.getF_csvt_obligate1());
        map.put("f_csvt_activityid",acv.getF_csvt_activityid());
        Integer rowCount = acDao.acSvcVoteTotalCount(map);
        return rowCount;
	}
    public Integer updateAc(CmVoteTotalVo acv){
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("f_csvt_id",acv.getF_csvt_id());
        map.put("f_csvt_votecount",acv.getF_csvt_votecount());
       return acDao.updateAc(map);
    }
    public Integer insertAc(CmVoteTotalVo acv){
       return acDao.insertAc(acv);
    }
    
    public CmVoteTotalVo selectAcInfo(CmVoteTotalVo apv){
	    Map<String,Object> map=new HashMap<String,Object>();
	    map.put("f_csvt_id",apv.getF_csvt_id());
        return acDao.selectAcInfo(apv);
    }
}
